from random import *
from time import *

class GuessNumberGame:

    def __init__(self, a = 0, b = 9) -> None:
        seed(time())
        self.number = randint(a, b)

    def newGame(self) -> None:
        self.number = randint(0, 9)

    def rightQ(self, number) -> bool:
        if self.number == number:
            return True
        return False

    def hint(self, number) -> None:
        if number == self.number:
            print("猜对了，重新开始游戏")
        elif number > self.number:
            print("猜大了")
        elif number < self.number:
            print("猜小了")
        return

    def _showNumber(self) -> None:
        print(self.number)


game = GuessNumberGame()
while 1:
    user_guess = eval(input("请猜一个数字(0~9):"))
    game.hint(user_guess)
    if game.rightQ(user_guess):
        game.newGame()
